<?php
/**
 * Created by zwl
 * User: 需要验证的API接口, 都要继承这个父类
 * Date: 17-10-16
 */

namespace Common\Controller;

use Think\Controller;

class CommonController extends Controller
{
    // 验证用户是否合法
    protected function _initialize() {
        // 获取当前用户ID
        $user_id = I('user_id', 0, 'intval');
        $level_id = I('level_id', 0, 'invtal');
        if ($user_id <= 0 || $level_id <= 0) {
            $this->ajaxReturn(['status' => 0, 'msg' => 'Parameter error!']);
        }
    }

    // 判断是不是POST方法
    protected function isPost(){
        if (!IS_POST) {
            $this->ajaxReturn(array('staus' => 0, 'msg' => 'i need post mothod!'));
            die;
        }
    }
}
